package com.xjgc.eip.task;

import com.xjgc.eip.panel.service.*;
import com.xjgc.eip.service.ZxjEip2CPutService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

public class Task{

	@Autowired
	ZxjEip2CPutService zxjEip2CPutService;
	ZxjEipScddService zxjEipScddService;
	@Autowired
	ZxjEipGdService zxjEipGdService;
	@Autowired
	ZxjEipPcjhService zxjEipPcjhService;
	@Autowired
	ZxjEipCpxxService zxjEipCpxxService;
	@Autowired
	ZxjEipBgService zxjEipBgService;
	@Autowired
	ZxjEipXsddService zxjEipXsddService;

	private static boolean isRunning = false;
	private static boolean isBomRunning = false;
	private static boolean isBkkcRunning = false;
	private static final Logger LOG = LoggerFactory.getLogger(Task.class);

	@Scheduled(fixedRate = 10*60*1000)
	public void tasks() {
		if(!isRunning){
			isRunning = true;
			LOG.info("任务开始");
//			zxjEip2CPutService.putData();
			isRunning = false;
			LOG.info("ָ任务结束");
		}
	}

	/*@Scheduled(fixedRate = 60*1000)
	public void bkkctasks() {
		if(!isBkkcRunning){
            isBkkcRunning = true;
			LOG.info("生产工艺路线接口定时任务开始");
            //zxjEip2cBkkcService.putData();
            isBkkcRunning = false;
			LOG.info("生产工艺路线接口定时ָ任务结束");
		}
	}*/

	/*@Scheduled(fixedRate = 60*1000)
	protected void scdd() throws Throwable {
		if(!isBkkcRunning){
			LOG.info("生产订单定时任务开始");
			isBomRunning = true;
			LOG.info("任务开始");
			zxjEipScddService.productOrder();
			isBomRunning = false;
			LOG.info("生产订单定时ָ任务结束");
		}
	}*/

	/*@Scheduled(fixedRate = 60*1000)
	public void pcjh() throws Throwable{
		if(!isBkkcRunning){
			LOG.info("排产计划定时任务开始");
			isBomRunning = true;
			LOG.info("任务开始");
			zxjEipPcjhService.producePlan();
			isBomRunning = false;
			LOG.info("排产计划定时ָ任务结束");
		}
	}*/

	/*@Scheduled(fixedRate = 60*1000)
	public void cpxx() throws Throwable{
		if(!isBkkcRunning){
			LOG.info("产品信息跟踪定时任务开始");
			isBomRunning = true;
			LOG.info("任务开始");
			zxjEipCpxxService.productInfo();
			isBomRunning = false;
			LOG.info("产品信息跟踪定时ָ任务结束");
		}
	}*/

	/*@Scheduled(fixedRate = 60*1000)
	public void bg() throws Throwable{
		if(!isBkkcRunning){
			LOG.info("报工定时任务开始");
			isBomRunning = true;
			LOG.info("任务开始");
			zxjEipBgService.workOrder();
			isBomRunning = false;
			LOG.info("报工定时ָ任务结束");
		}
	}*/

	/*@Scheduled(fixedRate = 60*1000)
	public void xsdd() throws Throwable{
		if(!isBkkcRunning){
			LOG.info("报工定时任务开始");
			isBomRunning = true;
			LOG.info("任务开始");
			zxjEipXsddService.salesOrder();
			isBomRunning = false;
			LOG.info("报工定时ָ任务结束");
		}
	}*/
//
//	@Scheduled(fixedRate = 60*1000)
//	public void gd() throws Throwable{
//		if(!isBkkcRunning){
//			LOG.info("生产工单定时任务开始");
//			isBomRunning = true;
//			LOG.info("任务开始");
//			//zxjEipGdService.workList();
//			isBomRunning = false;
//			LOG.info("生产工单定时ָ任务结束");
//		}
//	}
}
